﻿Public Class frmPrincipal

    Private panelInicio As New frmUsuariosInicio
    Private bCerrarSesion As Boolean 'indica si se presiona el boton Cerrar Sesion
    'Private usuarios As New frmUsuariosLista

    Private Sub frmPrincipal_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        panelInicio = frmUsuariosInicio.Inicio
        bCerrarSesion = False
        tssUsuario.Text = "Usuario: " + panelInicio.NombreUsuario
    End Sub

    Private Sub frmPrincipal_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If bCerrarSesion = False Then
            panelInicio.Salir()
        End If
    End Sub

    Private Sub UsuariosToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UsuariosToolStripMenuItem.Click

        Dim usuarios As frmUsuariosLista = New frmUsuariosLista
        usuarios.MdiParent = Me

        If panelInicio.Perfil = BE.PerfilUsuario.Cajero Then
            usuarios.Cajero()
            usuarios.Show()
        Else
            usuarios.Admin()
            usuarios.Show()
        End If

    End Sub

    Private Sub SalirToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SalirToolStripMenuItem.Click
        panelInicio.Salir()
    End Sub

    Private Sub CerrarSesiónToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CerrarSesiónToolStripMenuItem.Click
        bCerrarSesion = True
        panelInicio.CerrarSesion()
    End Sub

End Class
